import React from 'react';
import styles from './hdb-nav.module.css'
import propTypes from 'prop-types';
import {withRouter} from 'react-router-dom';

/*
*  props
*
*  bgColor:背景颜色
*  arrow: 'default, //箭头模式
*  borderWidth: 1, 边框宽度
*
* */

class HdbNav extends React.Component {

    static defaultProps = {
        bgColor:'#fff',
        arrow:'default',
        borderWidth:1
    };

    static propTypes = {
        bgColor:propTypes.string,
        arrow:propTypes.string,
        borderWidth:propTypes.number,
    };

    render() {
        let {bgColor,borderWidth,arrow,history,children} = this.props;
        return (
            <div
                className={styles.nav}
                style={{
                    background:bgColor,
                    borderWidth:borderWidth
                }}
            >
                <div className={styles.arrow}>
                    <div
                        className={styles[arrow]}
                        onClick={()=>history.go(-1)}
                    ></div>
                    {children}
                </div>
            </div>
        )
    }
}

export default withRouter(HdbNav)